package dao;
import java.sql.*;

public class DAOFactory {
	private static final String Driver= "com.mysql.jdbc.Driver";
    private static final String DBURL= "jdbc:mysql://localhost:3306/mydb";
    private static final String dbuser= "root";
    private static final String dbpass= "";
		
    public static  Connection c;

    public static void connect() throws Exception {
        try {
            Class.forName(Driver);
            c = DriverManager.getConnection(DBURL, dbuser, dbpass);
        } catch (Exception e) {
            throw new Exception("Neuspjelo povezivanje sa bazom.");
        }
    }

    public static void disconnect() throws Exception {
        try {
            c.close();
        } catch (Exception e) {
            throw new Exception("Neuspio prekid veze sa bazom.");
        }
    }
    
    
    public static MarketDAO getMarketDAO() throws Exception {
     	return new MarketDAO(c);
    }
    public static ArtikalDAO getArtikalDAO() throws Exception {
     	return new ArtikalDAO(c);
    }
    public static AkcijskiArtikalDAO getAkcijskiArtikalDAO() throws Exception {
     	return new AkcijskiArtikalDAO(c);
    }
    
    public static AkcijaDAO getAkcijaDAO() throws Exception {
     	return new AkcijaDAO(c);
    }
    
    public static TipDAO getTipDAO() throws Exception {
     	return new TipDAO(c);
    }
    
    public static VrstaDAO getVrstaDAO() throws Exception {
     	return new VrstaDAO(c);
    }
    
    public static ProizvodDAO getProizvodDAO() throws Exception {
     	return new ProizvodDAO(c);
    }
    
    public static PoslovnicaDAO getPoslovnicaDAO() throws Exception {
     	return new PoslovnicaDAO(c);
    }
    public static KorisnikDAO getKorisnikDAO() throws Exception {
     	return new KorisnikDAO(c);
    }
    public static NarudzbenicaDAO getNarudzbenicaDAO() throws Exception {
     	return new NarudzbenicaDAO(c);
    }
    public static VraceniArtikliDAO getVraceniArtikliDAO() throws Exception {
     	return new VraceniArtikliDAO(c);
    }
    public static StavkaDAO getStavkaDAO() throws Exception {
     	return new StavkaDAO(c);
    }
    	
}
